import * as ionIcons from '@vicons/ionicons5';
import {
  create,
  NBreadcrumb,
  NBreadcrumbItem,
  NButton,
  NDropdown,
  NForm,
  NFormItem,
  NIcon,
  NInput,
  NLayout,
  NLayoutSider,
  NMenu,
  NMessageProvider,
  NSpace,
  NDataTable,
  NSpin,
  NInputGroup,
  NCard,
  NTab,
  NTabPane,
  NTabs,
  NList,
  NListItem,
  NModal,
  NTree,
  NSelect,
  NRadio,
  NRadioGroup,
  NTreeSelect,
  NCheckboxGroup,
  NCheckbox,
  NWatermark,
  NSwitch,
  NGrid,
  NFormItemGi,
  NInputNumber,
  NConfigProvider,
} from 'naive-ui';

import type { App } from 'vue';

// 组件写在components中
export const components: any[] = [
  NBreadcrumb,
  NBreadcrumbItem,
  NButton,
  NDropdown,
  NForm,
  NFormItem,
  NIcon,
  NInput,
  NLayout,
  NLayoutSider,
  NMenu,
  NMessageProvider,
  NSpace,
  NDataTable,
  NSpin,
  NInputGroup,
  NCard,
  NTab,
  NTabPane,
  NTabs,
  NList,
  NListItem,
  NModal,
  NTree,
  NSelect,
  NRadio,
  NRadioGroup,
  NTreeSelect,
  NCheckboxGroup,
  NCheckbox,
  NWatermark,
  NSwitch,
  NGrid,
  NFormItemGi,
  NInputNumber,
  NConfigProvider,
];

export const naive = create({
  components,
});

export default {
  install(app: App) {
    app.use(naive);
    // 注册全局组件
    Object.keys(ionIcons).forEach((key) => {
      app.component(key, ionIcons[key as keyof typeof ionIcons]);
    });

    app.config.globalProperties.$ionIcons = ionIcons;
  },
};
